package com.dense.kuiniu.bookborrow.business.adapter;

import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dense.kuiniu.bookborrow.R;
import com.dense.kuiniu.bookborrow.business.entity.Book;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * @author Administrator
 * @date 2020/8/7
 */
public class BookTagAdapter extends BaseQuickAdapter<Book, BaseViewHolder> {
    public BookTagAdapter(int layoutResId, @Nullable List<Book> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, Book bookBean) {
        TextView tvName = baseViewHolder.findView(R.id.tv_name);
        if (tvName != null) {
            tvName.setText(bookBean.getBookName());
            GradientDrawable gradientDrawable = (GradientDrawable) tvName.getBackground();
            if (baseViewHolder.getAdapterPosition() != 0) {
                gradientDrawable.setColor(Color.parseColor("#4D81FF"));
            }else{
                gradientDrawable.setColor(Color.parseColor("#FFA61A"));
            }
        }


    }
}